﻿using System;
using System.Linq;
using Microsoft.Phone.Controls;
using Serene.Criteria;
using System.Windows;

namespace Serene.DemoWindowsPhoneApplication
{
    public partial class MainPage : PhoneApplicationPage
    {
        private readonly ISereneManager _sereneManager;

        public MainPage()
        {
            InitializeComponent();
            Loaded += MainPageLoaded;
            _sereneManager = new SereneManager(new[] { new BasicUsageCriteria(0, 2) });
        }

        void MainPageLoaded(object sender, RoutedEventArgs e)
        {
            _sereneManager.RunCriteria();
            _sereneManager.RedirectToMarketPlaceIfRequired("Would you like to rate this application now?", "Serene", DateTime.Now.AddDays(14));
        }
    }
}